package com.xinya.taobaosale.model.domain;

import com.xinya.taobaosale.model.ApiException;

/**
 * @ClassName: ResultBean$
 * @Description: java类作用描述
 * @Author: xinya
 * @CreateDate: 2021/2/1$ 19:56$
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
public class ResultBean<T> {

    /**
     * success : true
     * code : 10000
     * message : 获取分类成功.
     * data : null
     */

    private boolean success;
    private int code;
    private String message;
    private T data;
    private static final int SUCCESS_CODE = 10000;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() throws ApiException {
        if (!isSuccess() || getCode() != SUCCESS_CODE || data == null) {
            throw new ApiException(code, message);
        }
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
